<template>
  <div class="fixed">
    <div class="top">
      <span @click="close">
        <svg-icon icon-class="back" class="icon" />
      </span>
      <span>设置真实姓名</span>
      <span class="link" @click="save">保存</span>
    </div>
    <van-field v-model="value" placeholder="请输入真实姓名" autofocus />
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      value: null
    };
  },
  created() {
    this.value = this.data || null;
  },
  methods: {
    save() {
      if (!this.value) return this.$toast.fail("请输入真实姓名");
      this.$toast.success("保存成功！");
      this.close();
    },
    close() {
      this.$emit("close", this.value || null);
    }
  }
};
</script>
